package scala40rules;


import java.io.Serializable;

public class Deck implements Serializable {
	

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	
	private CardSet deck = new CardSet();
	private static final Deck DECK_INSTANCE = new Deck();
	
	private Deck(){
		SuitList suitList = new SuitList();
		//System.out.println("[Deck] suitList.size()= "+suitList.size());
		//System.out.println("[Deck] suitList.size()= "+suitList.size());
		
		
		
		//System.out.println("\n\n\n[Deck]\n[suitList.getSuit(j)] [suitList.getSuit(i)]");
//		for(int i=0; i<suitList.size(); i++){
//			for (int j=0; j<suitList.size()-1; j++){
//				//System.out.println("["+suitList.getSuit(j)+" ("+j+")]                   ["+suitList.getSuit(i)+" ("+i+")]");
//				deck.add(new Card (j+1, suitList.getSuit(j), suitList.getSuit(i), redBack));
//				deck.add(new Card (j+1, suitList.getSuit(j), suitList.getSuit(i), blueBack));
//			}
//		}
		// aggiunta 4 jolly
//		for(int i=0; i<2 ; i++){
//			deck.add(new Card(suitList.size(), suitList.getSuit(13), " ", redBack));
//			deck.add(new Card(suitList.size(), suitList.getSuit(13), " ", blueBack));
//		}
		
		deck.addCard(new Card(14, "Joker", " ",true, "src/cards/joker.png","src/small_cards/joker.png"));
		deck.addCard(new Card(14, "Joker", " ",true, "src/cards/joker.png","src/small_cards/joker.png"));
		deck.addCard(new Card(14, "Joker", " ",true, "src/cards/joker.png","src/small_cards/joker.png"));
		deck.addCard(new Card(14, "Joker", " ",true, "src/cards/joker.png","src/small_cards/joker.png"));
		
	    deck.addCard(new Card(1,"A", suitList.getSuit(0),true, "src/cards/asso_cuori.png","src/small_cards/asso_cuori.png"));
	    deck.addCard(new Card(2,"2", suitList.getSuit(0),true, "src/cards/due_cuori.png","src/small_cards/due_cuori.png"));
	    deck.addCard(new Card(3,"3", suitList.getSuit(0),true, "src/cards/tre_cuori.png","src/small_cards/tre_cuori.png"));
	    deck.addCard(new Card(4,"4", suitList.getSuit(0),true, "src/cards/quattro_cuori.png","src/small_cards/quattro_cuori.png"));
	    deck.addCard(new Card(5,"5", suitList.getSuit(0),true, "src/cards/cinque_cuori.png","src/small_cards/cinque_cuori.png"));
	    deck.addCard(new Card(6,"6", suitList.getSuit(0),true, "src/cards/sei_cuori.png","src/small_cards/sei_cuori.png"));
	    deck.addCard(new Card(7,"7", suitList.getSuit(0),true, "src/cards/sette_cuori.png","src/small_cards/sette_cuori.png"));
	    deck.addCard(new Card(8,"8", suitList.getSuit(0),true, "src/cards/otto_cuori.png","src/small_cards/otto_cuori.png"));
	    deck.addCard(new Card(9,"9", suitList.getSuit(0),true, "src/cards/nove_cuori.png","src/small_cards/nove_cuori.png"));
	    deck.addCard(new Card(10,"10", suitList.getSuit(0),true, "src/cards/dieci_cuori.png","src/small_cards/dieci_cuori.png"));
	    deck.addCard(new Card(11,"J", suitList.getSuit(0),true, "src/cards/jack_cuori.png","src/small_cards/jack_cuori.png"));
	    deck.addCard(new Card(12,"Q", suitList.getSuit(0),true, "src/cards/donna_cuori.png","src/small_cards/donna_cuori.png"));
	    deck.addCard(new Card(13,"K", suitList.getSuit(0),true, "src/cards/re_cuori.png","src/small_cards/re_cuori.png"));
	    
	    deck.addCard(new Card(1,"A", suitList.getSuit(1),true, "src/cards/asso_fiori.png","src/small_cards/asso_fiori.png"));
	    deck.addCard(new Card(2,"2", suitList.getSuit(1),true, "src/cards/due_fiori.png","src/small_cards/due_fiori.png"));
	    deck.addCard(new Card(3,"3", suitList.getSuit(1),true, "src/cards/tre_fiori.png","src/small_cards/tre_fiori.png"));
	    deck.addCard(new Card(4,"4", suitList.getSuit(1),true, "src/cards/quattro_fiori.png","src/small_cards/quattro_fiori.png"));
	    deck.addCard(new Card(5,"5", suitList.getSuit(1),true, "src/cards/cinque_fiori.png","src/small_cards/cinque_fiori.png"));
	    deck.addCard(new Card(6,"6", suitList.getSuit(1),true, "src/cards/sei_fiori.png","src/small_cards/sei_fiori.png"));
	    deck.addCard(new Card(7,"7", suitList.getSuit(1),true, "src/cards/sette_fiori.png","src/small_cards/sette_fiori.png"));
	    deck.addCard(new Card(8,"8", suitList.getSuit(1),true, "src/cards/otto_fiori.png","src/small_cards/otto_fiori.png"));
	    deck.addCard(new Card(9,"9", suitList.getSuit(1),true, "src/cards/nove_fiori.png","src/small_cards/nove_fiori.png"));
	    deck.addCard(new Card(10,"10", suitList.getSuit(1),true, "src/cards/dieci_fiori.png","src/small_cards/dieci_fiori.png"));
	    deck.addCard(new Card(11,"J", suitList.getSuit(1),true, "src/cards/jack_fiori.png","src/small_cards/jack_fiori.png"));
	    deck.addCard(new Card(12,"Q", suitList.getSuit(1),true, "src/cards/donna_fiori.png","src/small_cards/donna_fiori.png"));
	    deck.addCard(new Card(13,"K", suitList.getSuit(1),true, "src/cards/re_fiori.png","src/small_cards/re_fiori.png"));
	    
	    deck.addCard(new Card(1,"A", suitList.getSuit(2),true, "src/cards/asso_quadri.png","src/small_cards/asso_quadri.png"));
	    deck.addCard(new Card(2,"2", suitList.getSuit(2),true, "src/cards/due_quadri.png","src/small_cards/due_quadri.png"));
	    deck.addCard(new Card(3,"3", suitList.getSuit(2),true, "src/cards/tre_quadri.png","src/small_cards/tre_quadri.png"));
	    deck.addCard(new Card(4,"4", suitList.getSuit(2),true, "src/cards/quattro_quadri.png","src/small_cards/quattro_quadri.png"));
	    deck.addCard(new Card(5,"5", suitList.getSuit(2),true, "src/cards/cinque_quadri.png","src/small_cards/cinque_quadri.png"));
	    deck.addCard(new Card(6,"6", suitList.getSuit(2),true, "src/cards/sei_quadri.png","src/small_cards/sei_quadri.png"));
	    deck.addCard(new Card(7,"7", suitList.getSuit(2),true, "src/cards/sette_quadri.png","src/small_cards/sette_quadri.png"));
	    deck.addCard(new Card(8,"8", suitList.getSuit(2),true, "src/cards/otto_quadri.png","src/small_cards/otto_quadri.png"));
	    deck.addCard(new Card(9,"9", suitList.getSuit(2),true, "src/cards/nove_quadri.png","src/small_cards/nove_quadri.png"));
	    deck.addCard(new Card(10,"10", suitList.getSuit(2),true, "src/cards/dieci_quadri.png","src/small_cards/dieci_quadri.png"));
	    deck.addCard(new Card(11,"J", suitList.getSuit(2),true, "src/cards/jack_quadri.png","src/small_cards/jack_quadri.png"));
	    deck.addCard(new Card(12,"Q", suitList.getSuit(2),true, "src/cards/donna_quadri.png","src/small_cards/donna_quadri.png"));
	    deck.addCard(new Card(13,"K", suitList.getSuit(2),true, "src/cards/re_quadri.png","src/small_cards/re_quadri.png"));
		
	    deck.addCard(new Card(1,"A", suitList.getSuit(3),true, "src/cards/asso_picche.png","src/small_cards/asso_picche.png"));
	    deck.addCard(new Card(2,"2", suitList.getSuit(3),true, "src/cards/due_picche.png","src/small_cards/due_picche.png"));
	    deck.addCard(new Card(3,"3", suitList.getSuit(3),true, "src/cards/tre_picche.png","src/small_cards/tre_picche.png"));
	    deck.addCard(new Card(4,"4", suitList.getSuit(3),true, "src/cards/quattro_picche.png","src/small_cards/quattro_picche.png"));
	    deck.addCard(new Card(5,"5", suitList.getSuit(3),true, "src/cards/cinque_picche.png","src/small_cards/cinque_picche.png"));
	    deck.addCard(new Card(6,"6", suitList.getSuit(3),true, "src/cards/sei_picche.png","src/small_cards/sei_picche.png"));
	    deck.addCard(new Card(7,"7", suitList.getSuit(3),true, "src/cards/sette_picche.png","src/small_cards/sette_picche.png"));
	    deck.addCard(new Card(8,"8", suitList.getSuit(3),true, "src/cards/otto_picche.png","src/small_cards/otto_picche.png"));
	    deck.addCard(new Card(9,"9", suitList.getSuit(3),true, "src/cards/nove_picche.png","src/small_cards/nove_picche.png"));
	    deck.addCard(new Card(10,"10", suitList.getSuit(3),true, "src/cards/dieci_picche.png","src/small_cards/dieci_picche.png"));
	    deck.addCard(new Card(11,"J", suitList.getSuit(3),true, "src/cards/jack_picche.png","src/small_cards/jack_picche.png"));
	    deck.addCard(new Card(12,"Q", suitList.getSuit(3),true, "src/cards/donna_picche.png","src/small_cards/donna_picche.png"));
	    deck.addCard(new Card(13,"K", suitList.getSuit(3),true, "src/cards/re_picche.png","src/small_cards/re_picche.png"));
	    
	    deck.addCard(new Card(1,"A", suitList.getSuit(0),false, "src/cards/asso_cuori.png","src/small_cards/asso_cuori.png"));
	    deck.addCard(new Card(2,"2", suitList.getSuit(0),false, "src/cards/due_cuori.png","src/small_cards/due_cuori.png"));
	    deck.addCard(new Card(3,"3", suitList.getSuit(0),false, "src/cards/tre_cuori.png","src/small_cards/tre_cuori.png"));
	    deck.addCard(new Card(4,"4", suitList.getSuit(0),false, "src/cards/quattro_cuori.png","src/small_cards/quattro_cuori.png"));
	    deck.addCard(new Card(5,"5", suitList.getSuit(0),false, "src/cards/cinque_cuori.png","src/small_cards/cinque_cuori.png"));
	    deck.addCard(new Card(6,"6", suitList.getSuit(0),false, "src/cards/sei_cuori.png","src/small_cards/sei_cuori.png"));
	    deck.addCard(new Card(7,"7", suitList.getSuit(0),false, "src/cards/sette_cuori.png","src/small_cards/sette_cuori.png"));
	    deck.addCard(new Card(8,"8", suitList.getSuit(0),false, "src/cards/otto_cuori.png","src/small_cards/otto_cuori.png"));
	    deck.addCard(new Card(9,"9", suitList.getSuit(0),false, "src/cards/nove_cuori.png","src/small_cards/nove_cuori.png"));
	    deck.addCard(new Card(10,"10", suitList.getSuit(0),false, "src/cards/dieci_cuori.png","src/small_cards/dieci_cuori.png"));
	    deck.addCard(new Card(11,"J", suitList.getSuit(0),false, "src/cards/jack_cuori.png","src/small_cards/jack_cuori.png"));
	    deck.addCard(new Card(12,"Q", suitList.getSuit(0),false, "src/cards/donna_cuori.png","src/small_cards/donna_cuori.png"));
	    deck.addCard(new Card(13,"K", suitList.getSuit(0),false, "src/cards/re_cuori.png","src/small_cards/re_cuori.png"));
	    
	    deck.addCard(new Card(1,"A", suitList.getSuit(1),false, "src/cards/asso_fiori.png","src/small_cards/asso_fiori.png"));
	    deck.addCard(new Card(2,"2", suitList.getSuit(1),false, "src/cards/due_fiori.png","src/small_cards/due_fiori.png"));
	    deck.addCard(new Card(3,"3", suitList.getSuit(1),false, "src/cards/tre_fiori.png","src/small_cards/tre_fiori.png"));
	    deck.addCard(new Card(4,"4", suitList.getSuit(1),false, "src/cards/quattro_fiori.png","src/small_cards/quattro_fiori.png"));
	    deck.addCard(new Card(5,"5", suitList.getSuit(1),false, "src/cards/cinque_fiori.png","src/small_cards/cinque_fiori.png"));
	    deck.addCard(new Card(6,"6", suitList.getSuit(1),false, "src/cards/sei_fiori.png","src/small_cards/sei_fiori.png"));
	    deck.addCard(new Card(7,"7", suitList.getSuit(1),false, "src/cards/sette_fiori.png","src/small_cards/sette_fiori.png"));
	    deck.addCard(new Card(8,"8", suitList.getSuit(1),false, "src/cards/otto_fiori.png","src/small_cards/otto_fiori.png"));
	    deck.addCard(new Card(9,"9", suitList.getSuit(1),false, "src/cards/nove_fiori.png","src/small_cards/nove_fiori.png"));
	    deck.addCard(new Card(10,"10", suitList.getSuit(1),false, "src/cards/dieci_fiori.png","src/small_cards/dieci_fiori.png"));
	    deck.addCard(new Card(11,"J", suitList.getSuit(1),false, "src/cards/jack_fiori.png","src/small_cards/jack_fiori.png"));
	    deck.addCard(new Card(12,"Q", suitList.getSuit(1),false, "src/cards/donna_fiori.png","src/small_cards/donna_fiori.png"));
	    deck.addCard(new Card(13,"K", suitList.getSuit(1),false, "src/cards/re_fiori.png","src/small_cards/re_fiori.png"));
	    
	    deck.addCard(new Card(1,"A", suitList.getSuit(2),false, "src/cards/asso_quadri.png","src/small_cards/asso_quadri.png"));
	    deck.addCard(new Card(2,"2", suitList.getSuit(2),false, "src/cards/due_quadri.png","src/small_cards/due_quadri.png"));
	    deck.addCard(new Card(3,"3", suitList.getSuit(2),false, "src/cards/tre_quadri.png","src/small_cards/tre_quadri.png"));
	    deck.addCard(new Card(4,"4", suitList.getSuit(2),false, "src/cards/quattro_quadri.png","src/small_cards/quattro_quadri.png"));
	    deck.addCard(new Card(5,"5", suitList.getSuit(2),false, "src/cards/cinque_quadri.png","src/small_cards/cinque_quadri.png"));
	    deck.addCard(new Card(6,"6", suitList.getSuit(2),false, "src/cards/sei_quadri.png","src/small_cards/sei_quadri.png"));
	    deck.addCard(new Card(7,"7", suitList.getSuit(2),false, "src/cards/sette_quadri.png","src/small_cards/sette_quadri.png"));
	    deck.addCard(new Card(8,"8", suitList.getSuit(2),false, "src/cards/otto_quadri.png","src/small_cards/otto_quadri.png"));
	    deck.addCard(new Card(9,"9", suitList.getSuit(2),false, "src/cards/nove_quadri.png","src/small_cards/nove_quadri.png"));
	    deck.addCard(new Card(10,"10", suitList.getSuit(2),false, "src/cards/dieci_quadri.png","src/small_cards/dieci_quadri.png"));
	    deck.addCard(new Card(11,"J", suitList.getSuit(2),false, "src/cards/jack_quadri.png","src/small_cards/jack_quadri.png"));
	    deck.addCard(new Card(12,"Q", suitList.getSuit(2),false, "src/cards/donna_quadri.png","src/small_cards/donna_quadri.png"));
	    deck.addCard(new Card(13,"K", suitList.getSuit(2),false, "src/cards/re_quadri.png","src/small_cards/re_quadri.png"));
		
	    deck.addCard(new Card(1,"A", suitList.getSuit(3),false, "src/cards/asso_picche.png","src/small_cards/asso_picche.png"));
	    deck.addCard(new Card(2,"2", suitList.getSuit(3),false, "src/cards/due_picche.png","src/small_cards/due_picche.png"));
	    deck.addCard(new Card(3,"3", suitList.getSuit(3),false, "src/cards/tre_picche.png","src/small_cards/tre_picche.png"));
	    deck.addCard(new Card(4,"4", suitList.getSuit(3),false, "src/cards/quattro_picche.png","src/small_cards/quattro_picche.png"));
	    deck.addCard(new Card(5,"5", suitList.getSuit(3),false, "src/cards/cinque_picche.png","src/small_cards/cinque_picche.png"));
	    deck.addCard(new Card(6,"6", suitList.getSuit(3),false, "src/cards/sei_picche.png","src/small_cards/sei_picche.png"));
	    deck.addCard(new Card(7,"7", suitList.getSuit(3),false, "src/cards/sette_picche.png","src/small_cards/sette_picche.png"));
	    deck.addCard(new Card(8,"8", suitList.getSuit(3),false, "src/cards/otto_picche.png","src/small_cards/otto_picche.png"));
	    deck.addCard(new Card(9,"9", suitList.getSuit(3),false, "src/cards/nove_picche.png","src/small_cards/nove_picche.png"));
	    deck.addCard(new Card(10,"10", suitList.getSuit(3),false, "src/cards/dieci_picche.png","src/small_cards/dieci_picche.png"));
	    deck.addCard(new Card(11,"J", suitList.getSuit(3),false, "src/cards/jack_picche.png","src/small_cards/jack_picche.png"));
	    deck.addCard(new Card(12,"Q", suitList.getSuit(3),false, "src/cards/donna_picche.png","src/small_cards/donna_picche.png"));
	    deck.addCard(new Card(13,"K", suitList.getSuit(3),false, "src/cards/re_picche.png","src/small_cards/re_picche.png"));
		
	}
	
	
	
	public static synchronized Deck getInstance(){
		return DECK_INSTANCE;
	}
	
	public CardSet getDeck(){
		return deck;
	}
	
	public int size(){
		return deck.size();
	}
	
	//solo a scopo di testing
	public Card getCard(int cardPosition){
		return deck.getCard(cardPosition);
	}
	
}
